//
//  CYMeiZhouYiJianTableViewCell.m
//  cyydt
//
//  Created by chu on 2019/1/26.
//  Copyright © 2019 chu. All rights reserved.
//

#import "CYMeiZhouYiJianTableViewCell.h"

@implementation CYMeiZhouYiJianTableViewCell
+ (instancetype)initWithTableView:(UITableView *)tableView Identifier:(NSString *)identifier{
    CYMeiZhouYiJianTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
    if (!cell) {
        cell = [[NSBundle mainBundle] loadNibNamed:@"CYMeiZhouYiJianTableViewCell" owner:self options:nil][0];
    }
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    return cell;
}
- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
    self.backView.layer.cornerRadius = 5;
    self.backView.layer.masksToBounds = YES;
}
- (void)setModel:(CYProjectModel *)model{
    _model = model;
    [self.headImageView sd_setImageWithURL:[NSURL URLWithString:model.logo_item_sg] placeholderImage:[UIImage imageWithColor:[UIColor lightGrayColor] Size:self.headImageView.frame.size]];
    self.titleLabel.text = model.title;
    for (int i = [model.score intValue] + 1; i <= [model.score intValue]; i++) {
        if (i <= self.stars.count) {
            UIImageView *star = self.stars[i - 1];
            star.hidden = YES;
        }
    }
    self.introLabel.text = model.content;
    
    
    if ([model.funds isEqualToString:@"0"]) {
        self.moneyLabel.text = @"全部";
    }else if ([model.funds isEqualToString:@"10"]){
        self.moneyLabel.text = @"3万以下";
    }else if ([model.funds isEqualToString:@"15"]){
        self.moneyLabel.text = @"3-8万";
    }else if ([model.funds isEqualToString:@"5"]){
        self.moneyLabel.text = @"5-10万";
    }else if ([model.funds isEqualToString:@"6"]){
        self.moneyLabel.text = @"10-20万";
    }else if ([model.funds isEqualToString:@"11"]){
        self.moneyLabel.text = @"20万以上";
    }
    //标签
    [self.labelView.subviews makeObjectsPerformSelector:@selector(removeFromSuperview)];
    UIView *view = [[Tool sharedInstance] setSignView:model.customer andBackgroundColor:RGBOF(0xF5F7FB) andTitleColor:RGBOF(0x97A2B9) Height:20 andFont:[UIFont systemFontOfSize:12] andMargin_x:8 andMargin_y:8 andMaxWidth:kWindowW - 123];
    [self.labelView addSubview:view];
    self.labelViewHeightConstraint.constant = view.frame.size.height;
    
    self.introLabel.text = model.content;
    
    CGFloat titleheight = [[Tool sharedInstance] heightForString:model.title andWidth:kWindowW - 60 fontSize:15];
    CGFloat introHeight = [[Tool sharedInstance] heightForString:model.content andWidth:kWindowW - 60 - 58 fontSize:12];

    self.cellHeight = 300 + titleheight + view.frame.size.height + introHeight;
    
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
